package com.qidian.mes.sys.controller;

import com.qidian.mes.pojo.Dict;
import com.qidian.mes.sys.annotations.OptionLogAnno;
import com.qidian.mes.sys.service.DictService;
import com.qidian.mes.util.dot.PagerDTO;
import com.qidian.mes.util.pojo.QdResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * @Author 小可怎么都睡不够
 * @Company 起点编程
 * @Description
 * @Time 2024/4/2 10:42
 */
@CrossOrigin
@RestController
@RequestMapping("/dict")
@OptionLogAnno(module="字典管理")

public class DictController {
    @Autowired
    private DictService dictService;

    @GetMapping("/deletes")
    @OptionLogAnno(module = "批量删除")
    public QdResult deletes(Long [] dictId){
        return dictService.deletes(dictId);
    }

    @GetMapping("/delete")
    @OptionLogAnno(module = "删除")
    public QdResult deleteDict(Long dictId){
        return dictService.deleteDict(dictId);
    }
    @PostMapping("/update")
    @OptionLogAnno(module = "修改")
    public QdResult updateDict(@RequestBody Dict dict){
        return dictService.updateDict(dict);
    }

    @GetMapping("/queryById")
    public QdResult<Dict> queryById( Long dictId){

        return dictService.queryById(dictId);
    }
    @PostMapping("/save")
    @OptionLogAnno(module = "新增")
    public QdResult saveDict(@RequestBody Dict dict){
        return dictService.saveDict(dict);
    }

    @GetMapping("/queryByPage") // GetMapping只能接受get请求
    public QdResult<PagerDTO<Dict>> queryByPage(Dict sysDict, @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int limit){
        return dictService.queryByPage(sysDict,page,limit);
    }
    @RequestMapping("/queryAll")
    public QdResult<List<Dict>> queryAll(){
        return dictService.queryAll();
    }
}
